<div class="content">
	<div class="content_i">
    <?php
	 	// Thong tin dang nhap
		echo "<h2>";
			echo CHtml::image(Yii::app()->baseUrl."/assets/icon/icon-16-info.png");
			echo " Thông tin nhóm";
		echo "</h2>";
			
        echo CHtml::beginForm(array($this->controller_id."/save",
			"group_id"=>$row["id"], "page"=>$page),"post", array("id"=>"form_edit"));
			
		echo "<table cellpadding='3' cellspacing='0 border='0' width='50%'>";
			echo "<tr>";
				echo "<td class='label' width='150'>"."Nhóm cha"."</td>";
				echo "<td>";
				
				$list_parent_group = array(0=>"-- Nhóm cha --");
				
				$group_root = group::model()->find(array(
					"condition"=>"parent_id IS NULL OR parent_id = 0",
					"order" => "`order`"
				));
				
				$list_parent_group[$group_root->id] = $group_root->name;
				
				$subgroup_array = $group_root->sub_groups;
				foreach($subgroup_array as $subgroup)
				{
					$list_parent_group[$subgroup->id] = $subgroup->name;
				}
				
				echo CHtml::dropDownList("parent_id", $row["parent_id"], $list_parent_group);
				
				// Loai nhom
				echo "&nbsp;&nbsp;&nbsp;";
				echo "Loại nhóm ";
				$list_group_type = array(
					0 =>"Front-end",
					1 => "Back-end"
				);
				echo CHtml::dropDownList("backend", $row["backend"], $list_group_type);
				echo "</td>";
			echo "</tr>";
			
			echo "<tr>";
				echo "<td class='label' width='100'>"."Tên nhóm"."</td>";
				echo "<td>";
				echo CHtml::textField("name", $row["name"], array('style'=>'width:450px'));
				echo "</td>";
			echo "</tr>";
			
			echo "<tr>";
				echo "<td class='label' width='100'>"."Alias"."</td>";
				echo "<td>";
				echo CHtml::textField("alias", $row["alias"], array('style'=>'width:450px'));
				echo "</td>";
			echo "</tr>";
	
			
			echo "<tr>";
				echo "<td class='label'>"."Mô tả"."</td>";
				echo "<td>";
				echo CHtml::textField("desc", $row["desc"], array('style'=>'width:450px'));
				echo "</td>";
			echo "</tr>";
			
			echo "<tr>";
				echo "<td class='label'>"."Chuyên mục"."</td>";
				echo "<td>";
				
					$group_acategory_array = group_acategory::model()->findAll(array(
						"condition" => "group_id = " . $row->id
					));
					
					$acategory_array = array();
					$select = array();
					
					foreach($group_acategory_array as $group_acategory)
					{
						$select[] =  $group_acategory->acategory_id;
						$acategory_array[$group_acategory->acategory_id] = 
							acategory::model()->findByPk($group_acategory->acategory_id)->name;
					}
					
					echo CHtml::checkBoxList("acategory_id_array", $select, $group_acategory_array);
					
				echo "</td>";
			echo "</tr>";
			
			echo "<tr>";
				echo "<td>"."</td>";
				echo "<td>";
				
					// Submit Button
						echo "<div class='space_5'></div>";
	
						echo 
							"<div class='button' id='button_submit'>" .
								"<div style='float:left; width:20px;'>" .
									CHtml::image(Yii::app()->baseUrl."/assets/icon/icon-16-save.png") .
								"</div>" .
								"<div style='float:left; min-width:40px;font-weight:bold'>".
									"Save & Close" .
								"</div>" .
							"</div>";
							
						echo 
							"<div class='button' id='button_savenew'>" .
								"<div style='float:left; width:20px;'>" .
									CHtml::image(Yii::app()->baseUrl."/assets/icon/icon-16-plus.png") .
								"</div>" .
								"<div style='float:left; min-width:40px;font-weight:bold'>".
									" Save & New" .
								"</div>" .
							"</div>";
						
						echo 
							"<div class='button' id='button_apply'>" .
								"<div style='float:left; width:20px;'>" .
									CHtml::image(Yii::app()->baseUrl."/assets/icon/icon-16-tick.png") .
								"</div>" .
								"<div style='float:left; min-width:40px;font-weight:bold'>".
									" Apply" .
								"</div>" .
							"</div>";
						
						echo 
							"<div class='button' id='button_cancel'>" .
								"<div style='float:left; width:20px;'>" .
									CHtml::image(Yii::app()->baseUrl."/assets/icon/icon-16-check.png") .
								"</div>" .
								"<div style='float:left; min-width:50px;font-weight:bold'>".
									"Cancel" .
								"</div>" .
							"</div>";
				echo "</td>";
			echo "</tr>";
				
		echo "</table>";
		echo CHtml::endForm();
	?>
    </div>
</div><!-- end div right -->

<script language="javascript">
$(document).ready(function(){

	$('#button_submit').click(function(){
		$('#form_edit').submit();
	});
	
	$('#button_savenew').click(function(){
		$('#form_edit').attr("action","<?php
			echo Yii::app()->createUrl(
				$this->module_id."/" . $this->controller_id."/savenew",
				array("group_id"=>$row["id"], "page"=>$page)
			);
		?>");
		$('#form_edit').submit();
	});
	
	$('#button_apply').click(function(){
		$('#form_edit').attr("action","<?php
			echo Yii::app()->createUrl(
				$this->module_id."/" . $this->controller_id."/apply",
				array("group_id"=>$row["id"], "page"=>$page)
			);
		?>");
		$('#form_edit').submit();
	});
	
	$('#button_cancel').click(function(){
		window.location = '<?php
			$url = Yii::app()->createUrl(
				$this->route . "/view",
				array("page" =>$page)
			);
			echo $url;
		?>';
	});
});
</script>